package vcp.views;

import java.awt.event.ActionListener;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JOptionPane;

import client.Message;

import vcp.common.AbstractView;
import vcp.common.IView;
import vcp.gui.forms.ComplaintForm;

/**
 * Complaints view
 */
public class ComplaintsView extends AbstractView implements Observer,IView {
   
	ComplaintForm complaintsForm;

	public ComplaintsView(){		
		complaintsForm = new ComplaintForm();
	}
	
	public ComplaintForm getComplaintsForm() {
		return complaintsForm;
	}
	
	@Override
	public void addController(Object obj) {
		complaintsForm.getBtnSend().addActionListener((ActionListener)obj);
	}

	@Override
	public void update(Observable o, Object arg) {
		Message tempMsg = (Message)arg;  
		switch(tempMsg.getMsg())
		 {
		 	case "SubmitComplaint":
				if(tempMsg.isStatus())
				{
					JOptionPane.showMessageDialog(null , "Your Complaint have been Commited");
				}	
				else
				{
					JOptionPane.showMessageDialog(null,"Complaint has Failed: " + tempMsg.getStatusMsg(),"DATABASE ERROR",JOptionPane.ERROR_MESSAGE);
				}
				break;
		 }	
	}

}
